<template>
  <div class="q-exception">
    <a-row class="q-exception-row">
      <a-col :span="3">
        <q-language-select></q-language-select>
      </a-col>
    </a-row>
    <a-result :status="type" :title="type" :sub-title="$t('component.qException.desc'+type)">
      <template #extra>
        <a-button type="primary" @click="handleToHome">
          {{ toHome ? $t('component.qException.backHome') : $t('component.qException.backWorkbench')}}
        </a-button>
      </template>
    </a-result>
  </div>
</template>

<script>
import QLanguageSelect from '@/components/QLanguageSelect'
export default {
  name: 'QException',
  components: {
    QLanguageSelect
  },
  props: {
    type: {
      type: String,
      default: '404'
    }
  },
  data () {
    return {
      toHome: true
    }
  },
  created () {
    const token = window.sessionStorage.getItem('access_token')
    this.toHome = token ? false : true
  },
  methods: {
    handleToHome () {
      if (this.toHome) {
        this.$router.push({ name: 'index' })
      } else {
        this.$router.push({ path: '/defaultPage'})
      }
    }
  }
}
</script>
<style lang="less" scoped>
  .q-exception{
    padding-top: 20px;
  }
</style>
